package nix.mybatis.dao;

import java.util.List;

import nix.mybatis.pojo.User;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;


public class UserDaoImpl implements UserDao {

	private SqlSessionFactory sqlSessionFactory;

	public UserDaoImpl(SqlSessionFactory sqlSessionFactory) {
		this.sqlSessionFactory = sqlSessionFactory;
	}
	
	public User findById(Integer id) {
		SqlSession sqlSession = this.sqlSessionFactory.openSession();
		return sqlSession.selectOne("user.findById", id);
	}
	
	public List<User> findListByUsername(String username) {
		SqlSession sqlSession = this.sqlSessionFactory.openSession();
		return sqlSession.selectList("user.findListByUsername", username);
	}
}
